package com.sky.mapper;


import com.sky.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

/**
 * @author Morpeko
 * @description 针对表【user(用户信息)】的数据库操作Mapper
 * @createDate 2024-08-13 21:33:08
 * @Entity com.sky.pojo.User
 */
@Mapper
public interface UserMapper {
    @Select("SELECT id, openid, name, phone, sex, id_number, avatar, create_time  FROM user WHERE openid = #{openid}")
    User login(String openid);

    /**
     * 插入新用户(注册)
     *
     * @param newUser
     */
    void registerUser(User newUser);

    /**
     * 根据用户id获取用户信息
     *
     * @param userId
     * @return
     */
    @Select("select id, openid, name, phone, sex, id_number, avatar, create_time" +
            " from user where id=#{userId}")
    User getById(Long userId);

    /**
     * 查询新增用户数
     * @param map
     * @return
     */
    @Select("select count(id) from user where create_time >= #{begin} and create_time <= #{end} ")
    Integer countByMap(Map map);
}




